<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<html>
<head>
    <title>借书</title>
    <link rel="stylesheet" type="text/css" href="<s:url value="/inc/style.css"/>">
    <script type="text/javascript" src="<s:url value="/js/jquery.js"/>"></script>
</head>
<body>
<center>
    <s:action name="header" executeResult="true" namespace="/"/>
    <table width="900">
        <tr>
            <td height="20">当前位置>>借书</td>
        </tr>
    </table>
    <table width="900" border="1" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC" bordercolordark="#FFFFFF"  bordercolorlight="#888888">
        <tr bgcolor="#DDDDEE">
            <td height="35" width="20%">书籍编号</td>
            <td width="20%">书名</td>
            <td width="20%">类别</td>
            <td width="20%">借书时间</td>
            <td width="20%">操作</td>
        </tr>
        <s:iterator value="list" id="b">
            <tr>
                <td height="35"><s:property value="#b.bookId"/></td>
                <td><s:property value="#b.bookName"/></td>
                <td><s:property value="#b.categoryName"/></td>
                <td><s:date name="#b.createTime" format="yyyy-MM-dd HH:mm:ss" /></td>
                <td><input type="button" data="<s:property value="#b.bookId"/>" class="lend_book_btn" value="还书"></td>
            </tr>
        </s:iterator>
    </table>
</center>
</body>
<script type="text/javascript">
    function refreshPage(){
        self.location.href="<s:url value="/lend_list.action"/>";
    }
    $(function(){
        $(".lend_book_btn").click(function(){
            var id = $(this).attr("data");
            $.ajax({
                type : "GET",
                url : '<s:url value="/lend_back.action"/>?id='+id+'&cback=?',
                dataType : "jsonp",
                jsonp: 'callback',
                success : function(json) {
                    alert(json.resultInfo);
                    refreshPage();
                }
            });
        })
    });
</script>
</html>
